package com.scuec.tourismwebsite.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.scuec.tourismwebsite.mapper.AttractionPopularityMapper;

import com.scuec.tourismwebsite.vo.PopularityAttraction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttractionPopularityServiceImpl implements AttractionPopularityService {

    @Autowired
    private AttractionPopularityMapper attractionPopularityMapper;

    @Override
    public List<PopularityAttraction> getAllAttractionPopularity() {
        return attractionPopularityMapper.getAllAttractionPopularity();
    }
    @Override
    public List<PopularityAttraction> findAttractionByName(String attraction_name) {
        return attractionPopularityMapper.findAttractionByName(attraction_name);
    }


    @Override
    public int deleteAttractionPopularityById(int popularity_id) {
        return 0;
    }

    @Override
    public PageInfo<PopularityAttraction> findPopularityPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PopularityAttraction> lists = attractionPopularityMapper.getAllAttractionPopularity();
        PageInfo<PopularityAttraction> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<PopularityAttraction> findPopularityPage(String attraction_name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PopularityAttraction> lists = attractionPopularityMapper.findAttractionByName(attraction_name);
        PageInfo<PopularityAttraction> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

}
